Creating the Navigation Toolbar

Description

The NavigationToolbar toolbar provides an alternative mechanism for displaying the different forms of the AlphaSports application. Looking at the definition of the Invoices button, you can see that the Button Action is "Play Global Script" and the Script Name is "invoice_form" - the same properties as BUTTON1 , thereby reusing the invoice_form script.

images/AL_NavigationToolbar_invoices_Xbasic.gif

Procedure: Creating the NavigationToolbar

The following procedure assumes that the developer has opened the form in the Form Editor and has created all the reference scripts.Follow these instructions to create a toolbar similar to the Navigation Toolbar.

  1. Click the Code tab of the Control Panel.

  2. Select New > Toolbar.

  3. Select "Blank Toolbar" and click OK to display the Toolbar Editor.

  4. Click Free-form Xdialog 'XD' button.

  5. Select "No break" in the Before Xdialog list of the Toolbar Buttons tab.

  6. Select "Always" in the Show Button list.

  7. Click Define Xdialog Code..., enter the following Xdialog code on the Xdialog Body tab, then click OK. This line writes the word "AlphaSports" using the 10 point bold dark blue Tahoma font. For more information, refer to Learning Xdialog.

    ' Create a title for the toolbar
    {'%O={C=Dark Blue}{F=Tahoma,10,B} AlphaSports %};
    {font=}
  8. Click Add Separator Line.

  9. Click Add Custom Button.

  10. Enter "Home" in the Text field.

  11. Enter "Go to the AlphaSports Home Page" in the Bubble Help field.

  12. Select "Play Global Script" in the Button Action list.

  13. Enter "main_menu" in the Script Name field.

  14. Repeat steps 9 through 13 with the following values for the Text, Bubble Help, and Script Name fields. Select "Play Global Script" in the Button Action list for all entries. Button Text:

  15. Click Add Separator Line.

  16. Click Add Custom Button.

  17. Enter "Close Navigator" in the Text field.

  18. Enter "Close the Navigator Toolbar" in the Bubble Help field.

  19. Select "Run Xbasic" in the Button Action list.

  20. Click the edit button to display the Code Editor dialog box.

    images/Edit_Button_2.gif
  21. Type the following Xbasic code and click OK.

  22. Click OK to return to the Toolbar Editor.

    ui_modeless_dlg_close("navigator")
    if (is_object(main_menu.this)) then
            :Main_Menu:Vcshownavbar.Text = "No"
    end if
  23. Click Add Separator Line.

  24. Click Free-form Xdialog 'XD' button.

  25. Click Define Xdialog Code..., enter the following Xdialog code on the Xdialog Body tab, then click OK. This line creates 80 lines of blank text that pushes the bottom line of the toolbar off the bottom of the screen. For more information, refer to Learning Xdialog.

    ' Push the closing separator to the bottom of the screen.
    {text=15,80:dummy_text};
  26. Click Save to return to the Control Panel.

An Explanation of the Xbasic Code

The first line of code uses the ui_modeless_dlg_close() function to close the Navigation toolbar.

ui_modeless_dlg_close("navigator")

The next line uses the is_object() function to test if the Main Menu form is open. If it is, it un-checks the menu option to display the toolbar. See vCshowNavBar on<x>change Event.

if (is_object(main_menu.this)) then
    :Main_Menu:Vcshownavbar.Text = "No"
end if

See Also